<template>
  <van-nav-bar
    :title="title"
  
    @click-left="onClickLeft"
    @click-right="onClickRight"
  >
    <template #left v-if="show">
      <van-icon name="arrow-left" size="24" />
      <span style="line-height: 46px; color: #1889fa">返回</span>
    </template>
    <template #right v-if="show1">
      <van-popover @select="clickOneDone" class="mypop"  placement="bottom-end"  v-model="showPopover" trigger="click" :actions="actions">
        <template #reference>
          <van-icon  name="add-o" size="24" />
        </template>
      </van-popover>
    </template>
  </van-nav-bar>
</template>

<script>
export default {
  props: {
    title: String,
    show: {
      type: Boolean,
      default: false,
   
    },
    show1:{
        type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      showPopover: false,
      flag:false,
      actions: [
        { text: "搜索", icon: "search",name:"search" },
        { text: "登录", icon: "friends-o" ,name:"login"},
        { text: "扫一扫", icon: "scan" ,name:"phone"},
      ],
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
   
      this.showPopover = true;
    },
    clickOneDone(action,index){
      // console.log(action);
      // console.log(index);
     if(this.$route.name !== action.name){
        this.$router.push({
        name:action.name
      })
     }
    }
  },
};
</script>
<style leng="scss" scoped>
.van-popover__action-text{
    text-align: center;
}
::v-deep .mypop {
    margin-top: 10px;
}


</style>